cmake_minimum_required(VERSION 3.12)
message(STATUS "cmake version ${CMAKE_VERSION}")

project(rknn_yolov8)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(TOOLCHAIN_DIR /opt/gcc-aarch64-linux-gnu)

set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-g++)

set(SYSROOT ${TOOLCHAIN_DIR})

set(CMAKE_CXX_STANDARD 11)

add_definitions(-g -O0 -ggdb -gdwarf -funwind-tables -rdynamic)
add_definitions(-Wno-write-strings -Wno-return-type)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -Wall -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -Wall -fPIC")


include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/**/*.c)

set(LIBS pthread)

set(LIBRARIES_DIR = ${CMAKE_CURRENT_SOURCE_DIR}/libraries)

# yolov8
set(RKNN_PATH ${LIBRARIES_DIR}/yolov8)
include_directories(${RKNN_PATH}/include)
file(GLOB RKNN_SOURCES 
        ${RKNN_PATH}/src/*.cc
        ${RKNN_PATH}/utils/*.c
    )
list(APPEND SOURCES ${RKNN_SOURCES})
list(APPEND LIBS rknnrt turbojpeg)
link_directories(${RKNN_PATH}/lib)

# rga
set(RGA_PATH ${LIBRARIES_DIR}/librga)
include_directories(${RGA_PATH}/include)
list(APPEND LIBS rga)
link_directories(${RGA_PATH}/lib)

# drm
set(DRM_PATH ${LIBRARIES_DIR}/libdrm)
include_directories(${DRM_PATH}/include)
list(APPEND LIBS drm)
link_directories(${DRM_PATH}/lib)

set(APP rknn_yolov8_flip)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)

add_executable(${APP} ${CMAKE_CURRENT_SOURCE_DIR}/${APP}.cc ${SOURCES})

target_link_libraries(${APP} ${LIBS})

 
